1 Question

Does a higher ICU admission and hospitalization predict a higher mortality rate in developing countries like Malaysia, and Chile compared to developed countries like the United States, and Switzerland?

2 Data setup

2.1 Library

library(tidyverse)
library(readxl)
library(tibble)
library(janitor)
library(reshape2)
library(ggplot2)
library(ggthemes)
library(plotly)
library(pheatmap)
library(maps)
library(zoo)
library(proxy)
library(DT)
library(limma)
library(RSpectra)
library(dplyr)
library(lubridate)
library(GGally)
# library(randomcoloR)
library(forecast)

# For url
library(XML)
library(RCurl)
library(rlist)

2.2 About data

For this lab, we will examine the global collection of COVID-19 statistics maintained by Our World in Data. The information is updated daily and includes data on confirmed cases, deaths, number of administered vaccination and many others. To find out more details about this data resources, please check out the detailed overview described on their website and GitHub repository https://github.com/owid/covid-19-data/tree/master/public/data/. The aim is to study the collective time-varying trends in number of cases and infectivity of COVID-19. We approach this problem by first studying the 25 most severely impacted countries by way of total case numbers. These are: United States, India, Brazil, France, UK, Russia, Turkey, Italy, Germany, Spain, Argentina, Iran, Colombia, Poland, Mexico, Netherlands, Indonesia, Ukraine, South Africa, Philippines, Peru, Belgium, Czechia, Japan, Israel.
在本实验室中,我们将检查由 Our World in Data 维护的 COVID-19 统计数据的全球集合。该信息每天更新,包括确诊病例、死亡人数、接种疫苗次数等数据。要了解有关此数据资源的更多详细信息,请查看其网站和 GitHub 存储库 https://github.com/owid/covid-19-data/tree/master/public/data/ 上描述的详细概述。目的是研究 COVID-19 病例数和传染性的集体随时间变化趋势。我们首先通过总病例数研究 25 个受影响最严重的国家来解决这个问题。它们是:美国、印度、巴西、法国、英国、俄罗斯、土耳其、意大利、德国、西班牙、阿根廷、伊朗、哥伦比亚、波兰、墨西哥、荷兰、印度尼西亚、乌克兰、南非、菲律宾、秘鲁、比利时、捷克、日本、以色列。

United States, Singapore, Philippines, Switzerland.

2.3 Data input and extraction

We encourage you to extract data directly from the web and repeat the lab. If your computer lab is fully reproducible, you will find that you do not need to change your code when you update your result. The pre-downloaded data from 16th February 2022 is given to you as “owid-covid-data-160222.csv”.
我们鼓励您直接从网络中提取数据并重复该实验。如果您的计算机实验室是完全可重现的,您会发现在更新结果时不需要更改代码。 2022 年 2 月 16 日的预下载数据以”owid-covid-data-160222.csv”的形式提供给您。

[a] The data in “owid-covid-data-160222.csv” contains a lot of COVID-19 related information for each country, such as new cases, new deaths, icu patients, new tests etc, as well as the demography statistics for each country. Read in the data for the selected 25 countries and extract the data between 2020-06-01 and 2021-12-30. Name your R data object as covid. Check to see the column date is coded as the class Date and extract data related selected counties. Consider ways to double check that you have extract the data correctly.
“owid-covid-data-160222.csv”中的数据包含每个国家的大量 COVID-19 相关信息,例如新病例、新死亡、ICU 患者、新测试等,以及人口统计每个国家的统计数据。读取选定的 25 个国家/地区的数据,提取 2020-06-01 和 2021-12-30 之间的数据。将您的 R 数据对象命名为 covid。检查以查看列日期被编码为类日期并提取与所选县相关的数据。考虑仔细检查您是否正确提取数据的方法。

# 所有地区icu的新增数据的计算(基于每日的统计量)
new_icu_covid_function <- function(location_icu_full) {
  new_icu_list <- c()
  is_first_time = TRUE
  for (i in 1:length(location_icu_full$icu_covid)) {
    if (is_first_time){
      new_icu = location_icu_full$icu_covid[i]
      is_first_time = FALSE
    }
    else {
      new_icu = location_icu_full$icu_covid[i] - location_icu_full$icu_covid[i-1]
    }
    new_icu_list <- append(new_icu_list, new_icu)
  }
  location_icu_full <- cbind(location_icu_full, new_icu_covid = new_icu_list)
  return(location_icu_full)
}
# Read in dataset 所有数据导入工作

# covid主数据
# covid <- read.csv("data/owid-covid-data-160222.csv")
covid <- read.csv("https://github.com/owid/covid-19-data/raw/master/public/data/owid-covid-data.csv")

covid_used <- covid[c("location",
                      "date",
                      "new_cases_smoothed",
                      "new_cases_smoothed_per_million",
                      "new_deaths_smoothed",
                      "new_deaths_smoothed_per_million",
                      "population",
                      "population_density",
                      "human_development_index")]

# ---

# icu数据 - Chile
# chile_icu_patient <- read.csv("https://github.com/MinCiencia/Datos-COVID19/raw/master/output/producto8/UCI_T.csv")
chile_icu_full <- read.csv("https://github.com/MinCiencia/Datos-COVID19/raw/master/output/producto20/NumeroVentiladores_T.csv")

# chile_icu_patient <- rename(chile_icu_patient, date = Region)
# chile_icu_patient <- chile_icu_patient[-1:-2,]
# chile_icu_patient <- cbind(rowSums(chile_icu_patient[,-1]), chile_icu_patient)
# chile_icu_patient <- rename(chile_icu_patient, icu_patients = `rowSums(chile_icu_patient[, -1])`)
# chile_icu_patient <- chile_icu_patient[1:2]

chile_icu_full <- rename(chile_icu_full, c(date = Ventiladores, beds_icu = total, icu_covid = disponibles, icu_free = ocupados))
# chile_icu_full <- merge(chile_icu_patient, chile_icu_bed, by = "date")
chile_icu_full <- cbind(location = "Chile", chile_icu_full)

# rm("chile_icu_patient", "chile_icu_bed")

chile_icu_full <- rename(chile_icu_full, icu_total = beds_icu)
chile_icu_full <- cbind(chile_icu_full, icu_occupancy_rate = chile_icu_full$icu_covid / chile_icu_full$icu_total * 100)
chile_icu_full <- new_icu_covid_function(chile_icu_full)

# chile_icu_full <- cbind(chile_icu_full, new_icu_covid = chile_new_icu)
# rm(is_first_time)
# rm(chile_new_icu)

# ---

# icu数据 - Malaysia
# malaysia_icu_full <- read.csv("data/icu.csv")
malaysia_icu_full <- read.csv("https://raw.githubusercontent.com/MoH-Malaysia/covid19-public/main/epidemic/icu.csv")
# https://github.com/MoH-Malaysia/covid19-public/tree/main/epidemic#icu

malaysia_icu_full <- malaysia_icu_full[, -2]
malaysia_icu_full <- aggregate(cbind(beds_icu_total, icu_covid) ~ date, data = malaysia_icu_full, sum)
malaysia_icu_full <- cbind(location = "Malaysia", malaysia_icu_full)
malaysia_icu_full <- rename(malaysia_icu_full, icu_total = beds_icu_total)
malaysia_icu_full <- cbind(malaysia_icu_full, icu_free = malaysia_icu_full$icu_total - malaysia_icu_full$icu_covid)
malaysia_icu_full <- cbind(malaysia_icu_full, icu_occupancy_rate = malaysia_icu_full$icu_covid / malaysia_icu_full$icu_total * 100)
malaysia_icu_full <- new_icu_covid_function(malaysia_icu_full)

# ---

# icu数据 - United_states
# united_states_icu_full <- read.csv("data/COVID-19_Reported_Patient_Impact_and_Hospital_Capacity_by_State_Timeseries.csv")
united_states_icu_full <- read.csv("https://healthdata.gov/api/views/g62h-syeh/rows.csv?accessType=DOWNLOAD")

united_states_icu_full <- united_states_icu_full[, -1]
united_states_icu_full <- aggregate(cbind(total_staffed_adult_icu_beds, staffed_icu_adult_patients_confirmed_covid) ~ date, data = united_states_icu_full, sum)
united_states_icu_full <- cbind(location = "United States", united_states_icu_full)
united_states_icu_full <- rename(united_states_icu_full, icu_total = total_staffed_adult_icu_beds)
united_states_icu_full <- rename(united_states_icu_full, icu_covid = staffed_icu_adult_patients_confirmed_covid)
united_states_icu_full <- cbind(united_states_icu_full, icu_free = united_states_icu_full$icu_total - united_states_icu_full$icu_covid)
united_states_icu_full <- cbind(united_states_icu_full, icu_occupancy_rate = united_states_icu_full$icu_covid / united_states_icu_full$icu_total * 100)
united_states_icu_full <- new_icu_covid_function(united_states_icu_full)

# ---

# icu数据 - Switzerland
# switzerland_icu_full <- read.csv("data/bag_covid_19_data_csv_03_May_2022/COVID19HospCapacity_geoRegion.csv")

temp <- tempfile()
temp2 <- tempfile()
download.file("https://www.covid19.admin.ch/api/data/20220503-ls6se5v3/downloads/sources-csv.zip", temp)
unzip(zipfile = temp, exdir = temp2)
switzerland_icu_full <- read.csv(file.path(temp2, "data/COVID19HospCapacity_geoRegion.csv"))
rm("temp", "temp2")

switzerland_icu_full <- switzerland_icu_full[, -2]
switzerland_icu_full <- aggregate(cbind(ICU_Capacity, ICU_Covid19Patients, ICU_FreeCapacity) ~ date, data = switzerland_icu_full, sum)
switzerland_icu_full <- cbind(location = "Switzerland", switzerland_icu_full)
switzerland_icu_full <- rename(switzerland_icu_full, icu_total = ICU_Capacity)
switzerland_icu_full <- rename(switzerland_icu_full, icu_covid = ICU_Covid19Patients)
switzerland_icu_full <- rename(switzerland_icu_full, icu_free = ICU_FreeCapacity)
switzerland_icu_full <- cbind(switzerland_icu_full, icu_occupancy_rate = switzerland_icu_full$icu_covid / switzerland_icu_full$icu_total * 100)
switzerland_icu_full <- new_icu_covid_function(switzerland_icu_full)

# ---

# ICU data
# current_covid_patients_icu <- read.csv("https://github.com/owid/covid-19-data/raw/master/public/data/hospitalizations/covid-hospitalizations.csv")
# current_covid_patients_icu <- read.csv("data/current-covid-patients-icu.csv")

# ---

# Developed country data

# WAY1
developed_countries_full <- filter(covid_used, human_development_index >= 0.854)
developed_countries <- unique(developed_countries_full$location)

covid_used$developed <- ifelse(
  covid_used$location %in% developed_countries,
  "Yes",
  "No")

# developing_countries <- test %>% #Filtering countries which are developing and already developed by their hdi(human development index)
#   filter(hdi < 0.854)
# developing_countries <- subset(developing_countries, location!="World")

# WAY2
# tables <- getURL("https://worldpopulationreview.com/country-rankings/developed-countries",.opts = list(ssl.verifypeer = FALSE)) %>% readHTMLTable()
# developed_countries_full <- tables[[1]]
# rm(tables)
# developed_countries_full <- read.csv("data/csvData.csv")
# Range of date
start_date <- "2020-06-01"
end_date <- "2021-12-31"

range_data <- function(data, start_date, end_date){
  data$date <- as.Date(data$date)
  data <- data[(data$date >= start_date & data$date <= end_date), ]
  return(data)
}

covid_used <- range_data(covid_used, start_date, end_date)
malaysia_icu_full <- range_data(malaysia_icu_full, start_date, end_date)
chile_icu_full <- range_data(chile_icu_full, start_date, end_date)
united_states_icu_full <- range_data(united_states_icu_full, start_date, end_date)
switzerland_icu_full <- range_data(switzerland_icu_full, start_date, end_date)
# List of countries to study

# countries <- c("United States",
#               "India",
#               "Brazil",
#               "France",
#               "United Kingdom",
#               "Russia",
#               "Turkey",
#               "Italy",
#               "Germany",
#               "Spain",
#               "Argentina",
#               "Iran",
#               "Colombia",
#               "Poland",
#               'Mexico',
#               "Netherlands",
#               "Indonesia",
#               "Ukraine",
#               "South Africa",
#               "Philippines",
#               "Peru",
#               "Belgium",
#               "Czechia",
#               "Japan",
#               "Israel")

# Q1中选择的几个问题
countries <- c("Chile",
              "Malaysia",
              "Switzerland",
              "United States")

countries <- sort(countries)

## selecting countries and required time period.
covid_used_selected <- covid_used[covid_used$location %in% countries, ]

## covid <- covid_full %>% filter(covid_full$location %in% countries) ## Alternative

covid_A6_k <- rbind(chile_icu_full, malaysia_icu_full, switzerland_icu_full, united_states_icu_full)

covid_A6_k <- merge(covid_used_selected, covid_A6_k, by = c("location", "date"))

covid_A6_k <- cbind(covid_A6_k, icu_total_per_million = covid_A6_k$icu_total / covid_A6_k$population * 1000000)
covid_A6_k <- cbind(covid_A6_k, icu_covid_per_million = covid_A6_k$icu_covid / covid_A6_k$population * 1000000)
covid_A6_k <- cbind(covid_A6_k, icu_free_per_million = covid_A6_k$icu_free / covid_A6_k$population * 1000000)
covid_A6_k <- cbind(covid_A6_k, new_icu_covid_per_million = covid_A6_k$new_icu_covid / covid_A6_k$population * 1000000)

covid_A6_k <- covid_A6_k %>% relocate(any_of(c(
  "location",
  "date",
  "developed",
  "new_cases_smoothed",
  "new_cases_smoothed_per_million",
  "new_deaths_smoothed",
  "new_deaths_smoothed_per_million",
  "new_icu_covid",
  "new_icu_covid_per_million",
  "icu_total",
  "icu_total_per_million",
  "icu_covid",
  "icu_covid_per_million",
  "icu_free",
  "icu_free_per_million",
  "icu_occupancy_rate",
  "population",
  "population_density",
  "human_development_index"
)))

# Don't forget to check whether you have read your data in correctly.
# table(as.character(covid_full$location))  
covid_A6_k_develop_number <- aggregate(
  list(new_cases_smoothed = covid_A6_k$new_cases_smoothed,
       new_deaths_smoothed = covid_A6_k$new_deaths_smoothed,
       new_icu_covid = covid_A6_k$new_icu_covid,
       icu_total = covid_A6_k$icu_total,
       icu_covid = covid_A6_k$icu_covid,
       icu_free = covid_A6_k$icu_free,
       population = covid_A6_k$population),
  by = list(date = covid_A6_k$date,
            developed = covid_A6_k$developed),
  sum)

covid_A6_k_develop_rate <- aggregate(
  list(new_cases_smoothed_per_million = covid_A6_k$new_cases_smoothed_per_million,
       new_deaths_smoothed_per_million = covid_A6_k$new_deaths_smoothed_per_million,
       new_icu_covid_per_million = covid_A6_k$new_icu_covid_per_million,
       icu_total_per_million = covid_A6_k$icu_total_per_million,
       icu_covid_per_million = covid_A6_k$icu_covid_per_million,
       icu_free_per_million = covid_A6_k$icu_free_per_million,
       icu_occupancy_rate = covid_A6_k$icu_occupancy_rate,
       population_density = covid_A6_k$population_density),
  by = list(date = covid_A6_k$date,
            developed = covid_A6_k$developed),
  mean)

covid_A6_k_develop <- merge(covid_A6_k_develop_number, covid_A6_k_develop_rate, by = c("date", "developed"))

covid_A6_k_develop <- covid_A6_k_develop %>% relocate(any_of(c(
  "date",
  "developed",
  "new_cases_smoothed",
  "new_cases_smoothed_per_million",
  "new_deaths_smoothed",
  "new_deaths_smoothed_per_million",
  "new_icu_covid",
  "new_icu_covid_per_million",
  "icu_total",
  "icu_total_per_million",
  "icu_covid",
  "icu_covid_per_million",
  "icu_free",
  "icu_free_per_million",
  "icu_occupancy_rate",
  "population",
  "population_density"
)))

rm("covid_A6_k_develop_number", "covid_A6_k_develop_rate")

2.4 Output data.csv

write.csv(covid_A6_k,"data/processed/covid_A6_ken.csv", row.names = FALSE)
write.csv(covid_A6_k_develop,"data/processed/covid_A6_ken_develop.csv", row.names = FALSE)

2.5 Initial data analysis

plot_new_cases_per_million <- ggplot(covid_A6_k, 
                                     aes(x = date,
                                         y = new_cases_smoothed_per_million,
                                         group = developed,
                                         color = location)
                                     ) +
  geom_line() + 
  ylab("Number of new cases") +
  ggtitle("plot_new_cases_per_million") +
  labs(color = "Country / Region")

plot_new_deaths_per_million <- ggplot(covid_A6_k,
                                      aes(x = date,
                                          y = new_deaths_smoothed_per_million,
                                          group = developed,
                                          color = location)
                                      ) +
  geom_line() + 
  ylab("Number of new deaths") +
  ggtitle("plot_new_deaths_per_million") +
  labs(color = "Country / Region")

plot_new_icu_covid_per_million <- ggplot(covid_A6_k, 
                                         aes(x = date,
                                             y = new_icu_covid_per_million,
                                             group = developed,
                                             color = location)
                                         ) +
  geom_line() + 
  ylab("Number of new covid ICU") +
  ggtitle("plot_new_icu_covid_per_million") +
  labs(color = "Country / Region")

plot_icu_occupancy_rate <- ggplot(covid_A6_k, 
                                  aes(x = date,
                                      y = icu_occupancy_rate,
                                      group = developed,
                                      color = location)
                                  ) +
  geom_line() + 
  ylab("Number of ICU occupancy rate") +
  ggtitle("plot_icu_occupancy_rate") +
  labs(color = "Country / Region")


# par(mfrow=c(1,3))
# 
# plot(plot_new_cases_smoothed_per_million)
# plot(plot_weekly_icu_admissions_per_million)
# plot(plot_new_deaths_smoothed_per_million)

ggplotly(plot_new_cases_per_million)
ggplotly(plot_new_deaths_per_million)
ggplotly(plot_new_icu_covid_per_million)
ggplotly(plot_icu_occupancy_rate)
plot_develop_new_cases_per_million <- ggplot(covid_A6_k_develop, 
                                     aes(x = date,
                                         y = new_cases_smoothed_per_million,
                                         group = developed,
                                         color = developed)
                                     ) +
  geom_line() + 
  ylab("Number of new cases") +
  ggtitle("plot_new_cases_per_million") +
  labs(color = "Developed Country / Region")

plot_develop_new_deaths_per_million <- ggplot(covid_A6_k_develop,
                                      aes(x = date,
                                          y = new_deaths_smoothed_per_million,
                                          group = developed,
                                          color = developed)
                                      ) +
  geom_line() + 
  ylab("Number of new deaths") +
  ggtitle("plot_new_deaths_per_million") +
  labs(color = "Developed Country / Region")

plot_develop_new_icu_covid_per_million <- ggplot(covid_A6_k_develop, 
                                         aes(x = date,
                                             y = new_icu_covid_per_million,
                                             group = developed,
                                             color = developed)
                                         ) +
  geom_line() + 
  ylab("Number of new covid ICU") +
  ggtitle("plot_new_icu_covid_per_million") +
  labs(color = "Developed Country / Region")

plot_develop_icu_occupancy_rate <- ggplot(covid_A6_k_develop, 
                                  aes(x = date,
                                      y = icu_occupancy_rate,
                                      group = developed,
                                      color = developed)
                                  ) +
  geom_line() + 
  ylab("Number of ICU occupancy rate") +
  ggtitle("plot_icu_occupancy_rate") +
  labs(color = "Developed Country / Region")

ggplotly(plot_develop_new_cases_per_million)
ggplotly(plot_develop_new_deaths_per_million)
ggplotly(plot_develop_new_icu_covid_per_million)
ggplotly(plot_develop_icu_occupancy_rate)

The figure above highlights the evolution of the reproduction rate for each country. Notably, there doesn’t appear to be a great deal of consistency between various countries’ behaviours. The amplitude, periodicity and general trends appears to display no global consistency. If you wish to isolate a single country, double click on a single country on the plotly and you can see it in an isolated setting.
上图突出了每个国家繁殖率的演变。 值得注意的是,各国的行为之间似乎没有很大的一致性。 幅度、周期性和总体趋势似乎没有显示出全局一致性。 如果你想孤立一个国家,在情节上双击一个国家,你可以在一个孤立的环境中看到它。

3 Verify

Functions

# logistic regression in new cases and icu and death in different location

covid_location_covid_A6_k <- function(covid, location_set) {
  if (location_set == "Yes" | location_set == "No") {
    covid_location <- filter(covid, developed == location_set)
    covid_location <- covid_location[c("developed",
                                       "date",
                                       "new_cases_smoothed_per_million",
                                       "new_deaths_smoothed_per_million",
                                       "new_icu_covid_per_million")]
    return(covid_location)
  }
  else {
    covid_location <- filter(covid, location == location_set)
    covid_location <- covid_location[c("location",
                                       "date",
                                       "new_cases_smoothed_per_million",
                                       "new_deaths_smoothed_per_million",
                                       "new_icu_covid_per_million")]
    return(covid_location)
  }
  
}

logi_cases_deaths_covid_A6_k <- function(covid, logi_location) {
  covid_location <- covid_location_covid_A6_k(covid, logi_location)
  logi_covid_location <- glm(formula = covid_location$new_cases_smoothed_per_million ~ covid_location$new_deaths_smoothed_per_million)
  return(summary(logi_covid_location))
}

logi_deaths_cases_covid_A6_k <- function(covid, logi_location) {
  covid_location <- covid_location_covid_A6_k(covid, logi_location)
  logi_covid_location <- glm(formula = covid_location$new_deaths_smoothed_per_million ~ covid_location$new_cases_smoothed_per_million)
  return(summary(logi_covid_location))
}

logi_cases_icu_covid_A6_k <- function(covid, logi_location) {
  covid_location <- covid_location_covid_A6_k(covid, logi_location)
  logi_covid_location <- glm(formula = covid_location$new_cases_smoothed_per_million ~ covid_location$new_icu_covid_per_million)
  return(summary(logi_covid_location))
}

logi_icu_cases_covid_A6_k <- function(covid, logi_location) {
  covid_location <- covid_location_covid_A6_k(covid, logi_location)
  logi_covid_location <- glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_cases_smoothed_per_million)
  return(summary(logi_covid_location))
}

logi_deaths_icu_covid_A6_k <- function(covid, logi_location) {
  covid_location <- covid_location_covid_A6_k(covid, logi_location)
  logi_covid_location <- glm(formula = covid_location$new_deaths_smoothed_per_million ~ covid_location$new_icu_covid_per_million)
  return(summary(logi_covid_location))
}

logi_icu_deaths_covid_A6_k <- function(covid, logi_location) {
  covid_location <- covid_location_covid_A6_k(covid, logi_location)
  logi_covid_location <- glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_deaths_smoothed_per_million)
  return(summary(logi_covid_location))
}

3.1 Logistic regression

3.1.1 By Countries

logi_cases_deaths_chile <- logi_cases_deaths_covid_A6_k(covid_A6_k, "Chile")
logi_cases_deaths_malaysia <- logi_cases_deaths_covid_A6_k(covid_A6_k, "Malaysia")
logi_cases_deaths_switzerland <- logi_cases_deaths_covid_A6_k(covid_A6_k, "Switzerland")
logi_cases_deaths_united_states <- logi_cases_deaths_covid_A6_k(covid_A6_k, "United States")

logi_deaths_cases_chile <- logi_deaths_cases_covid_A6_k(covid_A6_k, "Chile")
logi_deaths_cases_malaysia <- logi_deaths_cases_covid_A6_k(covid_A6_k, "Malaysia")
logi_deaths_cases_switzerland <- logi_deaths_cases_covid_A6_k(covid_A6_k, "Switzerland")
logi_deaths_cases_united_states <- logi_deaths_cases_covid_A6_k(covid_A6_k, "United States")

logi_cases_icu_chile <- logi_cases_icu_covid_A6_k(covid_A6_k, "Chile")
logi_cases_icu_malaysia <- logi_cases_icu_covid_A6_k(covid_A6_k, "Malaysia")
logi_cases_icu_switzerland <- logi_cases_icu_covid_A6_k(covid_A6_k, "Switzerland")
logi_cases_icu_united_states <- logi_cases_icu_covid_A6_k(covid_A6_k, "United States")

logi_icu_cases_chile <- logi_icu_cases_covid_A6_k(covid_A6_k, "Chile")
logi_icu_cases_malaysia <- logi_icu_cases_covid_A6_k(covid_A6_k, "Malaysia")
logi_icu_cases_switzerland <- logi_icu_cases_covid_A6_k(covid_A6_k, "Switzerland")
logi_icu_cases_united_states <- logi_icu_cases_covid_A6_k(covid_A6_k, "United States")

logi_deaths_icu_chile <- logi_deaths_icu_covid_A6_k(covid_A6_k, "Chile")
logi_deaths_icu_malaysia <- logi_deaths_icu_covid_A6_k(covid_A6_k, "Malaysia")
logi_deaths_icu_switzerland <- logi_deaths_icu_covid_A6_k(covid_A6_k, "Switzerland")
logi_deaths_icu_united_states <- logi_deaths_icu_covid_A6_k(covid_A6_k, "United States")

logi_icu_deaths_chile <- logi_icu_deaths_covid_A6_k(covid_A6_k, "Chile")
logi_icu_deaths_malaysia <- logi_icu_deaths_covid_A6_k(covid_A6_k, "Malaysia")
logi_icu_deaths_switzerland <- logi_icu_deaths_covid_A6_k(covid_A6_k, "Switzerland")
logi_icu_deaths_united_states <- logi_icu_deaths_covid_A6_k(covid_A6_k, "United States")
print(logi_cases_deaths_chile)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -193.77   -46.15   -12.18    55.64   177.23  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                      24.294      5.844   4.157
## covid_location$new_deaths_smoothed_per_million   38.319      1.499  25.567
##                                                Pr(>|t|)    
## (Intercept)                                    3.71e-05 ***
## covid_location$new_deaths_smoothed_per_million  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 5105.523)
## 
##     Null deviance: 6273094  on 576  degrees of freedom
## Residual deviance: 2935675  on 575  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 6567.9
## 
## Number of Fisher Scoring iterations: 2
print(logi_cases_deaths_malaysia)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -271.19   -41.06    -6.11    28.12   213.39  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                     43.3992     2.8832   15.05
## covid_location$new_deaths_smoothed_per_million  61.2595     0.9112   67.23
##                                                Pr(>|t|)    
## (Intercept)                                      <2e-16 ***
## covid_location$new_deaths_smoothed_per_million   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3506.804)
## 
##     Null deviance: 17872626  on 578  degrees of freedom
## Residual deviance:  2023426  on 577  degrees of freedom
## AIC: 6373.2
## 
## Number of Fisher Scoring iterations: 2
print(logi_cases_deaths_switzerland)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -216.50  -137.64   -78.63    25.02  1461.80  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                     150.232     11.991   12.53
## covid_location$new_deaths_smoothed_per_million   44.914      3.091   14.53
##                                                Pr(>|t|)    
## (Intercept)                                      <2e-16 ***
## covid_location$new_deaths_smoothed_per_million   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 56847.03)
## 
##     Null deviance: 43777224  on 560  degrees of freedom
## Residual deviance: 31777490  on 559  degrees of freedom
##   (18 observations deleted due to missingness)
## AIC: 7737.9
## 
## Number of Fisher Scoring iterations: 2
print(logi_cases_deaths_united_states)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -243.90   -68.44   -26.26    65.71   889.38  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                      41.657      9.706   4.292
## covid_location$new_deaths_smoothed_per_million   61.001      2.219  27.491
##                                                Pr(>|t|)    
## (Intercept)                                    2.08e-05 ***
## covid_location$new_deaths_smoothed_per_million  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 15336.43)
## 
##     Null deviance: 20439736  on 578  degrees of freedom
## Residual deviance:  8849122  on 577  degrees of freedom
## AIC: 7227.5
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_cases_chile)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.7592  -0.8353  -0.1539   0.3604   6.9866  
## 
## Coefficients:
##                                               Estimate Std. Error t value
## (Intercept)                                   1.233398   0.100502   12.27
## covid_location$new_cases_smoothed_per_million 0.013884   0.000543   25.57
##                                               Pr(>|t|)    
## (Intercept)                                     <2e-16 ***
## covid_location$new_cases_smoothed_per_million   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 1.849875)
## 
##     Null deviance: 2272.9  on 576  degrees of freedom
## Residual deviance: 1063.7  on 575  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 1996.4
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_cases_malaysia)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.5474  -0.4597  -0.0348   0.4148   5.1780  
## 
## Coefficients:
##                                                 Estimate Std. Error t value
## (Intercept)                                   -0.4416168  0.0489668  -9.019
## covid_location$new_cases_smoothed_per_million  0.0144759  0.0002153  67.228
##                                               Pr(>|t|)    
## (Intercept)                                     <2e-16 ***
## covid_location$new_cases_smoothed_per_million   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 0.8286738)
## 
##     Null deviance: 4223.38  on 578  degrees of freedom
## Residual deviance:  478.14  on 577  degrees of freedom
## AIC: 1538.3
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_cases_switzerland)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -8.6310  -1.0226  -0.6781  -0.4790   7.5161  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                   0.6132476  0.1560530    3.93
## covid_location$new_cases_smoothed_per_million 0.0061030  0.0004201   14.53
##                                               Pr(>|t|)    
## (Intercept)                                   9.57e-05 ***
## covid_location$new_cases_smoothed_per_million  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 7.72451)
## 
##     Null deviance: 5948.6  on 560  degrees of freedom
## Residual deviance: 4318.0  on 559  degrees of freedom
##   (18 observations deleted due to missingness)
## AIC: 2743
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_cases_united_states)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -8.1554  -0.7286  -0.2030   0.5309   4.5767  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                   1.2184078  0.1106459   11.01
## covid_location$new_cases_smoothed_per_million 0.0092960  0.0003381   27.49
##                                               Pr(>|t|)    
## (Intercept)                                     <2e-16 ***
## covid_location$new_cases_smoothed_per_million   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.337124)
## 
##     Null deviance: 3114.8  on 578  degrees of freedom
## Residual deviance: 1348.5  on 577  degrees of freedom
## AIC: 2138.7
## 
## Number of Fisher Scoring iterations: 2
print(logi_cases_icu_chile)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -136.59   -77.43   -46.91    64.58   231.10  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               152.691      4.335   35.22   <2e-16
## covid_location$new_icu_covid_per_million    3.771      4.143    0.91    0.363
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 10879.66)
## 
##     Null deviance: 6286579  on 578  degrees of freedom
## Residual deviance: 6277563  on 577  degrees of freedom
## AIC: 7028.7
## 
## Number of Fisher Scoring iterations: 2
print(logi_cases_icu_malaysia)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -184.23  -120.59   -60.99    35.89   566.09  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               144.813      7.268  19.926  < 2e-16
## covid_location$new_icu_covid_per_million  -31.636     11.415  -2.771  0.00576
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 30568.17)
## 
##     Null deviance: 17872626  on 578  degrees of freedom
## Residual deviance: 17637832  on 577  degrees of freedom
## AIC: 7626.9
## 
## Number of Fisher Scoring iterations: 2
print(logi_cases_icu_switzerland)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -411.48  -193.82   -87.50    84.28  1530.57  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               244.837     11.502  21.286  < 2e-16
## covid_location$new_icu_covid_per_million    9.212      2.119   4.348 1.63e-05
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 76474.7)
## 
##     Null deviance: 45571463  on 578  degrees of freedom
## Residual deviance: 44125905  on 577  degrees of freedom
## AIC: 8157.8
## 
## Number of Fisher Scoring iterations: 2
print(logi_cases_icu_united_states)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -340.22  -137.89   -60.49   109.05   899.53  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               266.960      7.816  34.157   <2e-16
## covid_location$new_icu_covid_per_million    9.803      5.342   1.835    0.067
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 35218.59)
## 
##     Null deviance: 20439736  on 578  degrees of freedom
## Residual deviance: 20321124  on 577  degrees of freedom
## AIC: 7708.9
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_cases_chile)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.8373  -0.6901  -0.0150   0.6318   4.3695  
## 
## Coefficients:
##                                                 Estimate Std. Error t value
## (Intercept)                                   -0.0648008  0.0772183  -0.839
## covid_location$new_cases_smoothed_per_million  0.0003803  0.0004178   0.910
##                                               Pr(>|t|)
## (Intercept)                                      0.402
## covid_location$new_cases_smoothed_per_million    0.363
## 
## (Dispersion parameter for gaussian family taken to be 1.097185)
## 
##     Null deviance: 633.99  on 578  degrees of freedom
## Residual deviance: 633.08  on 577  degrees of freedom
## AIC: 1700.8
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_cases_malaysia)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.9241  -0.2134  -0.0559   0.1604   3.6334  
## 
## Coefficients:
##                                                 Estimate Std. Error t value
## (Intercept)                                    0.0736038  0.0340736   2.160
## covid_location$new_cases_smoothed_per_million -0.0004153  0.0001498  -2.771
##                                               Pr(>|t|)   
## (Intercept)                                    0.03117 * 
## covid_location$new_cases_smoothed_per_million  0.00576 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 0.4012497)
## 
##     Null deviance: 234.60  on 578  degrees of freedom
## Residual deviance: 231.52  on 577  degrees of freedom
## AIC: 1118.4
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_deaths_switzerland)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -47.532   -2.565   -0.271    2.051   38.519  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                     0.27159    0.27687   0.981
## covid_location$new_deaths_smoothed_per_million -0.01086    0.07138  -0.152
##                                                Pr(>|t|)
## (Intercept)                                       0.327
## covid_location$new_deaths_smoothed_per_million    0.879
## 
## (Dispersion parameter for gaussian family taken to be 30.30636)
## 
##     Null deviance: 16942  on 560  degrees of freedom
## Residual deviance: 16941  on 559  degrees of freedom
##   (18 observations deleted due to missingness)
## AIC: 3509.8
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_cases_united_states)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.0459  -0.5191  -0.0274   0.4329  26.6911  
## 
## Coefficients:
##                                                 Estimate Std. Error t value
## (Intercept)                                   -0.0633050  0.1055490  -0.600
## covid_location$new_cases_smoothed_per_million  0.0005920  0.0003226   1.835
##                                               Pr(>|t|)  
## (Intercept)                                      0.549  
## covid_location$new_cases_smoothed_per_million    0.067 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.126764)
## 
##     Null deviance: 1234.3  on 578  degrees of freedom
## Residual deviance: 1227.1  on 577  degrees of freedom
## AIC: 2084
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_icu_chile)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -3.2725  -1.3852  -0.3746   1.2419   9.1706  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               3.35749    0.08243  40.730   <2e-16
## covid_location$new_icu_covid_per_million  0.17154    0.07883   2.176   0.0299
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3.92061)
## 
##     Null deviance: 2272.9  on 576  degrees of freedom
## Residual deviance: 2254.4  on 575  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 2429.8
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_icu_malaysia)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.5894  -1.6173  -1.2808   0.4422  11.7333  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                                1.6581     0.1109  14.952  < 2e-16
## covid_location$new_icu_covid_per_million  -0.7064     0.1742  -4.056 5.68e-05
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 7.116658)
## 
##     Null deviance: 4223.4  on 578  degrees of freedom
## Residual deviance: 4106.3  on 577  degrees of freedom
## AIC: 2783.4
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_icu_switzerland)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.1272  -1.9521  -1.3896  -0.1477   9.0979  
## 
## Coefficients:
##                                           Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               2.108861   0.137865  15.297   <2e-16
## covid_location$new_icu_covid_per_million -0.003812   0.025062  -0.152    0.879
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 10.64098)
## 
##     Null deviance: 5948.6  on 560  degrees of freedom
## Residual deviance: 5948.3  on 559  degrees of freedom
##   (18 observations deleted due to missingness)
## AIC: 2922.6
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_icu_united_states)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -3.2913  -1.6049  -0.7152   1.1588   7.2036  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               3.73951    0.09474  39.470  < 2e-16
## covid_location$new_icu_covid_per_million -0.32297    0.06475  -4.988 8.09e-07
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 5.175157)
## 
##     Null deviance: 3114.8  on 578  degrees of freedom
## Residual deviance: 2986.1  on 577  degrees of freedom
## AIC: 2598.9
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_deaths_chile)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.7679  -0.6872  -0.0283   0.6470   4.2020  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                    -0.16651    0.08533  -1.951
## covid_location$new_deaths_smoothed_per_million  0.04762    0.02188   2.176
##                                                Pr(>|t|)  
## (Intercept)                                      0.0515 .
## covid_location$new_deaths_smoothed_per_million   0.0299 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 1.088412)
## 
##     Null deviance: 630.99  on 576  degrees of freedom
## Residual deviance: 625.84  on 575  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 1690.3
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_deaths_malaysia)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -4.9257  -0.2229  -0.0698   0.1500   3.6203  
## 
## Coefficients:
##                                                 Estimate Std. Error t value
## (Intercept)                                     0.078333   0.030612   2.559
## covid_location$new_deaths_smoothed_per_million -0.039240   0.009675  -4.056
##                                                Pr(>|t|)    
## (Intercept)                                      0.0108 *  
## covid_location$new_deaths_smoothed_per_million 5.68e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 0.3953205)
## 
##     Null deviance: 234.6  on 578  degrees of freedom
## Residual deviance: 228.1  on 577  degrees of freedom
## AIC: 1109.8
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_deaths_switzerland)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -47.532   -2.565   -0.271    2.051   38.519  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                     0.27159    0.27687   0.981
## covid_location$new_deaths_smoothed_per_million -0.01086    0.07138  -0.152
##                                                Pr(>|t|)
## (Intercept)                                       0.327
## covid_location$new_deaths_smoothed_per_million    0.879
## 
## (Dispersion parameter for gaussian family taken to be 30.30636)
## 
##     Null deviance: 16942  on 560  degrees of freedom
## Residual deviance: 16941  on 559  degrees of freedom
##   (18 observations deleted due to missingness)
## AIC: 3509.8
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_deaths_united_states)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -6.2035  -0.6156  -0.2304   0.4187  26.4649  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                     0.56994    0.11224   5.078
## covid_location$new_deaths_smoothed_per_million -0.12798    0.02566  -4.988
##                                                Pr(>|t|)    
## (Intercept)                                    5.16e-07 ***
## covid_location$new_deaths_smoothed_per_million 8.09e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.050754)
## 
##     Null deviance: 1234.3  on 578  degrees of freedom
## Residual deviance: 1183.3  on 577  degrees of freedom
## AIC: 2063
## 
## Number of Fisher Scoring iterations: 2

3.1.2 By Develop

logi_cases_deaths_developed <- logi_cases_deaths_covid_A6_k(covid_A6_k_develop, "Yes")
logi_cases_deaths_developing <- logi_cases_deaths_covid_A6_k(covid_A6_k_develop, "No")

logi_deaths_cases_developed <- logi_deaths_cases_covid_A6_k(covid_A6_k_develop, "Yes")
logi_deaths_cases_developing <- logi_deaths_cases_covid_A6_k(covid_A6_k_develop, "No")

logi_cases_icu_developed <- logi_cases_icu_covid_A6_k(covid_A6_k_develop, "Yes")
logi_cases_icu_developing <- logi_cases_icu_covid_A6_k(covid_A6_k_develop, "No")

logi_icu_cases_developed <- logi_icu_cases_covid_A6_k(covid_A6_k_develop, "Yes")
logi_icu_cases_developing <- logi_icu_cases_covid_A6_k(covid_A6_k_develop, "No")

logi_deaths_icu_developed <- logi_deaths_icu_covid_A6_k(covid_A6_k_develop, "Yes")
logi_deaths_icu_developing <- logi_deaths_icu_covid_A6_k(covid_A6_k_develop, "No")

logi_icu_deaths_developed <- logi_icu_deaths_covid_A6_k(covid_A6_k_develop, "Yes")
logi_icu_deaths_developing <- logi_icu_deaths_covid_A6_k(covid_A6_k_develop, "No")
print(logi_cases_deaths_developed)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -217.49   -87.13   -52.47    29.49  1173.52  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                      92.475      9.976   9.269
## covid_location$new_deaths_smoothed_per_million   56.481      2.601  21.711
##                                                Pr(>|t|)    
## (Intercept)                                      <2e-16 ***
## covid_location$new_deaths_smoothed_per_million   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 24172.01)
## 
##     Null deviance: 24906566  on 560  degrees of freedom
## Residual deviance: 13512153  on 559  degrees of freedom
##   (18 observations deleted due to missingness)
## AIC: 7258.2
## 
## Number of Fisher Scoring iterations: 2
print(logi_cases_deaths_developing)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -177.903   -39.377     6.408    40.131   110.379  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                      25.986      4.095   6.346
## covid_location$new_deaths_smoothed_per_million   49.015      1.421  34.503
##                                                Pr(>|t|)    
## (Intercept)                                    4.47e-10 ***
## covid_location$new_deaths_smoothed_per_million  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2381.837)
## 
##     Null deviance: 4205087  on 576  degrees of freedom
## Residual deviance: 1369557  on 575  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 6128
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_cases_developed)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -9.3153  -0.8688  -0.3255   0.4353   4.3187  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                   0.8176594  0.1235736   6.617
## covid_location$new_cases_smoothed_per_million 0.0080998  0.0003731  21.711
##                                               Pr(>|t|)    
## (Intercept)                                   8.61e-11 ***
## covid_location$new_cases_smoothed_per_million  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3.46643)
## 
##     Null deviance: 3571.8  on 560  degrees of freedom
## Residual deviance: 1937.7  on 559  degrees of freedom
##   (18 observations deleted due to missingness)
## AIC: 2293.4
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_cases_developing)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.3424  -0.5663  -0.1344   0.3595   3.6768  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                   0.4575358  0.0683465   6.694
## covid_location$new_cases_smoothed_per_million 0.0137572  0.0003987  34.503
##                                               Pr(>|t|)    
## (Intercept)                                   5.16e-11 ***
## covid_location$new_cases_smoothed_per_million  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 0.6685151)
## 
##     Null deviance: 1180.3  on 576  degrees of freedom
## Residual deviance:  384.4  on 575  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 1409.1
## 
## Number of Fisher Scoring iterations: 2
print(logi_cases_icu_developed)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -291.45  -164.23   -65.93   123.75  1215.50  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               255.910      8.711  29.378  < 2e-16
## covid_location$new_icu_covid_per_million    9.320      2.975   3.133  0.00182
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 43806.75)
## 
##     Null deviance: 25706568  on 578  degrees of freedom
## Residual deviance: 25276494  on 577  degrees of freedom
## AIC: 7835.2
## 
## Number of Fisher Scoring iterations: 2
print(logi_cases_icu_developing)
## 
## Call:
## glm(formula = covid_location$new_cases_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -108.271   -86.596    -6.939    53.796   199.326  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               148.520      3.551  41.826   <2e-16
## covid_location$new_icu_covid_per_million    1.118      5.866   0.191    0.849
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 7300.177)
## 
##     Null deviance: 4212467  on 578  degrees of freedom
## Residual deviance: 4212202  on 577  degrees of freedom
## AIC: 6797.7
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_cases_developed)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -23.4436   -1.4081   -0.0623    1.2326   19.3494  
## 
## Coefficients:
##                                                 Estimate Std. Error t value
## (Intercept)                                   -0.3038025  0.1905650  -1.594
## covid_location$new_cases_smoothed_per_million  0.0017951  0.0005729   3.133
##                                               Pr(>|t|)   
## (Intercept)                                    0.11143   
## covid_location$new_cases_smoothed_per_million  0.00182 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 8.437216)
## 
##     Null deviance: 4951.1  on 578  degrees of freedom
## Residual deviance: 4868.3  on 577  degrees of freedom
## AIC: 2881.9
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_cases_developing)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_cases_smoothed_per_million)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -2.90104  -0.36066  -0.00858   0.34799   2.60271  
## 
## Coefficients:
##                                                 Estimate Std. Error t value
## (Intercept)                                   -4.913e-03  5.060e-02  -0.097
## covid_location$new_cases_smoothed_per_million  5.633e-05  2.954e-04   0.191
##                                               Pr(>|t|)
## (Intercept)                                      0.923
## covid_location$new_cases_smoothed_per_million    0.849
## 
## (Dispersion parameter for gaussian family taken to be 0.3677162)
## 
##     Null deviance: 212.19  on 578  degrees of freedom
## Residual deviance: 212.17  on 577  degrees of freedom
## AIC: 1067.9
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_icu_developed)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.8409  -1.7198  -0.9238   0.6070   6.8797  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               2.89950    0.10661  27.198   <2e-16
## covid_location$new_icu_covid_per_million -0.06492    0.03594  -1.806   0.0714
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 6.352497)
## 
##     Null deviance: 3571.8  on 560  degrees of freedom
## Residual deviance: 3551.0  on 559  degrees of freedom
##   (18 observations deleted due to missingness)
## AIC: 2633.2
## 
## Number of Fisher Scoring iterations: 2
print(logi_deaths_icu_developing)
## 
## Call:
## glm(formula = covid_location$new_deaths_smoothed_per_million ~ 
##     covid_location$new_icu_covid_per_million)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.6140  -1.2011  -0.4383   1.2776   4.3514  
## 
## Coefficients:
##                                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               2.50233    0.05964  41.957   <2e-16
## covid_location$new_icu_covid_per_million  0.02981    0.09879   0.302    0.763
##                                             
## (Intercept)                              ***
## covid_location$new_icu_covid_per_million    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.052284)
## 
##     Null deviance: 1180.3  on 576  degrees of freedom
## Residual deviance: 1180.1  on 575  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 2056.3
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_deaths_developed)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -23.7315   -1.5620   -0.3318    1.2816   19.0458  
## 
## Coefficients:
##                                                Estimate Std. Error t value
## (Intercept)                                     0.43788    0.18976   2.308
## covid_location$new_deaths_smoothed_per_million -0.08938    0.04948  -1.806
##                                                Pr(>|t|)  
## (Intercept)                                      0.0214 *
## covid_location$new_deaths_smoothed_per_million   0.0714 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 8.745178)
## 
##     Null deviance: 4917.1  on 560  degrees of freedom
## Residual deviance: 4888.6  on 559  degrees of freedom
##   (18 observations deleted due to missingness)
## AIC: 2812.6
## 
## Number of Fisher Scoring iterations: 2
print(logi_icu_deaths_developing)
## 
## Call:
## glm(formula = covid_location$new_icu_covid_per_million ~ covid_location$new_deaths_smoothed_per_million)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -2.90621  -0.35909  -0.00876   0.34728   2.59785  
## 
## Coefficients:
##                                                 Estimate Std. Error t value
## (Intercept)                                    -0.008725   0.050735  -0.172
## covid_location$new_deaths_smoothed_per_million  0.005312   0.017602   0.302
##                                                Pr(>|t|)
## (Intercept)                                       0.864
## covid_location$new_deaths_smoothed_per_million    0.763
## 
## (Dispersion parameter for gaussian family taken to be 0.3656768)
## 
##     Null deviance: 210.30  on 576  degrees of freedom
## Residual deviance: 210.26  on 575  degrees of freedom
##   (2 observations deleted due to missingness)
## AIC: 1061
## 
## Number of Fisher Scoring iterations: 2

3.2 Correlation

3.2.1 By Countries

new_c_d_i_chile <- covid_location_covid_A6_k(covid_A6_k, "Chile")
new_c_d_i_malaysia <- covid_location_covid_A6_k(covid_A6_k, "Malaysia")
new_c_d_i_switzerland <- covid_location_covid_A6_k(covid_A6_k, "Switzerland")
new_c_d_i_united_states <- covid_location_covid_A6_k(covid_A6_k, "United States")

cor_cases_deaths_icu_chile <- Hmisc::rcorr(as.matrix(new_c_d_i_chile[, 3:5]))
cor_cases_deaths_icu_chile$r[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                      0.03786974                      0.09038519 
##       new_icu_covid_per_million 
##                      1.00000000
cor_cases_deaths_icu_chile$P[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                      0.36303638                      0.02994149 
##       new_icu_covid_per_million 
##                              NA
ggpairs(new_c_d_i_chile, columns = 3:5)

cor_cases_deaths_icu_malaysia <- Hmisc::rcorr(as.matrix(new_c_d_i_malaysia[, 3:5]))
cor_cases_deaths_icu_malaysia$r[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                      -0.1146171                      -0.1664924 
##       new_icu_covid_per_million 
##                       1.0000000
cor_cases_deaths_icu_malaysia$P[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                    0.0057605419                    0.0000568102 
##       new_icu_covid_per_million 
##                              NA
ggpairs(new_c_d_i_malaysia, columns = 3:5)

cor_cases_deaths_icu_switzerland <- Hmisc::rcorr(as.matrix(new_c_d_i_switzerland[, 3:5]))
cor_cases_deaths_icu_switzerland$r[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                     0.178103023                    -0.006433335 
##       new_icu_covid_per_million 
##                     1.000000000
cor_cases_deaths_icu_switzerland$P[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                    1.626351e-05                    8.791569e-01 
##       new_icu_covid_per_million 
##                              NA
ggpairs(new_c_d_i_switzerland, columns = 3:5)

cor_cases_deaths_united_states <- Hmisc::rcorr(as.matrix(new_c_d_i_united_states[, 3:5]))
cor_cases_deaths_united_states$r[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                      0.07617732                     -0.20331089 
##       new_icu_covid_per_million 
##                      1.00000000
cor_cases_deaths_united_states$P[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                    6.699440e-02                    8.089554e-07 
##       new_icu_covid_per_million 
##                              NA
ggpairs(new_c_d_i_united_states, columns = 3:5)

3.2.2 By Develop

new_c_d_i_developed <- covid_location_covid_A6_k(covid_A6_k_develop, "Yes")
new_c_d_i_developing <- covid_location_covid_A6_k(covid_A6_k_develop, "No")

cor_cases_deaths_icu_developed <- Hmisc::rcorr(as.matrix(new_c_d_i_developed[, 3:5]))
cor_cases_deaths_icu_developed$r[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                      0.12934489                     -0.07617391 
##       new_icu_covid_per_million 
##                      1.00000000
cor_cases_deaths_icu_developed$P[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                      0.00181629                      0.07141835 
##       new_icu_covid_per_million 
##                              NA
ggpairs(new_c_d_i_developed, columns = 3:5)

cor_cases_deaths_icu_developing <- Hmisc::rcorr(as.matrix(new_c_d_i_developing[, 3:5]))
cor_cases_deaths_icu_developing$r[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                     0.007936416                     0.012584026 
##       new_icu_covid_per_million 
##                     1.000000000
cor_cases_deaths_icu_developing$P[3,]
##  new_cases_smoothed_per_million new_deaths_smoothed_per_million 
##                       0.8488706                       0.7629302 
##       new_icu_covid_per_million 
##                              NA
ggpairs(new_c_d_i_developing, columns = 3:5)

4 Model

4.1 ARIMA

4.1.1 By Countries

developed_countries <- filter(covid_A6_k, developed == "Yes")
developing_countries <- filter(covid_A6_k, developed == "No")

tsdisplay(developed_countries$new_icu_covid_per_million)

tsdisplay(developing_countries$new_icu_covid_per_million)

fit <- auto.arima(developed_countries$new_icu_covid_per_million)
forecast(fit, 30)
##      Point Forecast     Lo 80    Hi 80     Lo 95    Hi 95
## 1159     0.14047300 -4.440499 4.721445 -6.865519 7.146465
## 1160     0.57763100 -4.066359 5.221621 -6.524739 7.680001
## 1161     0.76916257 -3.885280 5.423605 -6.349193 7.887518
## 1162     0.70977451 -3.962670 5.382219 -6.436113 7.855662
## 1163     0.81256364 -3.873955 5.499082 -6.354848 7.979975
## 1164     0.95575655 -3.733517 5.645030 -6.215869 8.127382
## 1165     0.83252849 -3.894496 5.559553 -6.396832 8.061889
## 1166     0.71924759 -4.072683 5.511179 -6.609379 8.047874
## 1167     0.81345636 -3.993520 5.620433 -6.538180 8.165093
## 1168     0.78114509 -4.042539 5.604829 -6.596044 8.158334
## 1169     0.58702108 -4.297297 5.471340 -6.882899 8.056942
## 1170     0.57513805 -4.339585 5.489861 -6.941283 8.091559
## 1171     0.63826258 -4.281608 5.558134 -6.886031 8.162556
## 1172     0.49615405 -4.448950 5.441258 -7.066730 8.059038
## 1173     0.37434829 -4.608000 5.356697 -7.245496 7.994193
## 1174     0.44723182 -4.539746 5.434210 -7.179692 8.074156
## 1175     0.42484870 -4.565955 5.415653 -7.207928 8.057625
## 1176     0.26430201 -4.751605 5.280209 -7.406865 7.935469
## 1177     0.26240249 -4.763274 5.288079 -7.423706 7.948511
## 1178     0.33333636 -4.692423 5.359096 -7.352899 8.019572
## 1179     0.22860462 -4.804135 5.261344 -7.468306 7.925515
## 1180     0.13640104 -4.910388 5.183190 -7.581996 7.854798
## 1181     0.21432760 -4.832678 5.261333 -7.504402 7.933057
## 1182     0.21386748 -4.833230 5.260965 -7.505003 7.932738
## 1183     0.08946476 -4.967040 5.145970 -7.643792 7.822722
## 1184     0.09862338 -4.960548 5.157795 -7.638712 7.835959
## 1185     0.17450060 -4.885266 5.234267 -7.563744 7.912745
## 1186     0.09803740 -4.963429 5.159504 -7.642807 7.838882
## 1187     0.02659964 -5.040777 5.093976 -7.723283 7.776483
## 1188     0.10277680 -4.964691 5.170244 -7.647246 7.852799
plot(forecast(fit, 30))

fit <- auto.arima(developing_countries$new_icu_covid_per_million)
forecast(fit, 30)
##      Point Forecast     Lo 80    Hi 80     Lo 95    Hi 95
## 1159   1.336403e-02 -1.097017 1.123745 -1.684816 1.711545
## 1160   8.139009e-03 -1.102536 1.118814 -1.690492 1.706770
## 1161  -4.958801e-04 -1.111453 1.110461 -1.699558 1.698567
## 1162  -1.763532e-04 -1.111134 1.110782 -1.699240 1.698887
## 1163   1.550453e-05 -1.110943 1.110974 -1.699048 1.699079
## 1164   3.711476e-06 -1.110954 1.110962 -1.699060 1.699067
## 1165  -4.432394e-07 -1.110958 1.110958 -1.699064 1.699063
## 1166  -7.541596e-08 -1.110958 1.110958 -1.699064 1.699064
## 1167   1.196408e-08 -1.110958 1.110958 -1.699064 1.699064
## 1168   1.464274e-09 -1.110958 1.110958 -1.699064 1.699064
## 1169  -3.097725e-10 -1.110958 1.110958 -1.699064 1.699064
## 1170  -2.664494e-11 -1.110958 1.110958 -1.699064 1.699064
## 1171   7.760938e-12 -1.110958 1.110958 -1.699064 1.699064
## 1172   4.359032e-13 -1.110958 1.110958 -1.699064 1.699064
## 1173  -1.891020e-13 -1.110958 1.110958 -1.699064 1.699064
## 1174  -5.699434e-15 -1.110958 1.110958 -1.699064 1.699064
## 1175   4.494221e-15 -1.110958 1.110958 -1.699064 1.699064
## 1176   2.793297e-17 -1.110958 1.110958 -1.699064 1.699064
## 1177  -1.043326e-16 -1.110958 1.110958 -1.699064 1.699064
## 1178   1.759719e-18 -1.110958 1.110958 -1.699064 1.699064
## 1179   2.366570e-18 -1.110958 1.110958 -1.699064 1.699064
## 1180  -9.513335e-20 -1.110958 1.110958 -1.699064 1.699064
## 1181  -5.240837e-20 -1.110958 1.110958 -1.699064 1.699064
## 1182   3.402546e-21 -1.110958 1.110958 -1.699064 1.699064
## 1183   1.130739e-21 -1.110958 1.110958 -1.699064 1.699064
## 1184  -1.045583e-22 -1.110958 1.110958 -1.699064 1.699064
## 1185  -2.367859e-23 -1.110958 1.110958 -1.699064 1.699064
## 1186   2.957963e-24 -1.110958 1.110958 -1.699064 1.699064
## 1187   4.781415e-25 -1.110958 1.110958 -1.699064 1.699064
## 1188  -7.926295e-26 -1.110958 1.110958 -1.699064 1.699064
plot(forecast(fit, 30))

4.1.2 By Develop

developed_countries <- filter(covid_A6_k_develop, developed == "Yes")
developing_countries <- filter(covid_A6_k_develop, developed == "No")

tsdisplay(developed_countries$new_icu_covid_per_million)

tsdisplay(developing_countries$new_icu_covid_per_million)

fit <- auto.arima(developed_countries$new_icu_covid_per_million)
forecast(fit, 30)
##     Point Forecast     Lo 80    Hi 80     Lo 95    Hi 95
## 580     0.73633132 -2.575697 4.048359 -4.328978 5.801641
## 581     1.14350044 -2.211442 4.498443 -3.987441 6.274442
## 582     0.13139120 -3.231080 3.493862 -5.011065 5.273847
## 583    -0.49772334 -3.871756 2.876309 -5.657861 4.662414
## 584     0.27453723 -3.110326 3.659401 -4.902165 5.451240
## 585     0.21535614 -3.172176 3.602888 -4.965427 5.396139
## 586    -0.73129492 -4.145991 2.683401 -5.953622 4.491032
## 587    -0.41273165 -3.875571 3.050107 -5.708687 4.883224
## 588     0.27259965 -3.203772 3.748972 -5.044052 5.589252
## 589    -0.38196708 -3.872756 3.108822 -5.720668 4.956734
## 590    -0.78187648 -4.319785 2.756032 -6.192641 4.628888
## 591     0.02302542 -3.541528 3.587579 -5.428489 5.474540
## 592     0.07488055 -3.496027 3.645788 -5.386352 5.536113
## 593    -0.70185800 -4.295352 2.891636 -6.197633 4.793917
## 594    -0.38659037 -4.012915 3.239734 -5.932575 5.159394
## 595     0.26026106 -3.372518 3.893040 -5.295595 5.816118
## 596    -0.28946607 -3.927741 3.348809 -5.853728 5.274796
## 597    -0.64131737 -4.303398 3.020764 -6.241987 4.959352
## 598     0.07678773 -3.596676 3.750252 -5.541291 5.694866
## 599     0.13987280 -3.534612 3.814358 -5.479767 5.759513
## 600    -0.54863249 -4.231748 3.134483 -6.181471 5.084206
## 601    -0.28081339 -3.978927 3.417300 -5.936590 5.374963
## 602     0.29758632 -3.401812 3.996985 -5.360155 5.955328
## 603    -0.18401782 -3.884355 3.516320 -5.843196 5.475160
## 604    -0.50886148 -4.219886 3.202163 -6.184384 5.166661
## 605     0.12070516 -3.594520 3.835930 -5.561241 5.802652
## 606     0.18422298 -3.531002 3.899448 -5.497724 5.866169
## 607    -0.43098543 -4.149227 3.287256 -6.117545 5.255575
## 608    -0.20727669 -3.932595 3.518042 -5.904660 5.490106
## 609     0.30770889 -3.417705 4.033123 -5.389821 6.005238
plot(forecast(fit, 30))

fit <- auto.arima(developing_countries$new_icu_covid_per_million)
forecast(fit, 30)
##     Point Forecast      Lo 80     Hi 80     Lo 95    Hi 95
## 580     0.04540737 -0.7134836 0.8042984 -1.115216 1.206031
## 581     0.03760924 -0.7219829 0.7972014 -1.124087 1.199305
## 582     0.02905416 -0.7305954 0.7887037 -1.132730 1.190838
## 583    -0.07480923 -0.8383770 0.6887585 -1.242585 1.092967
## 584    -0.10698216 -0.8707917 0.6568273 -1.275128 1.061164
## 585    -0.11099581 -0.8764687 0.6544771 -1.281686 1.059694
## 586    -0.09499544 -0.8633147 0.6733238 -1.270038 1.080047
## 587    -0.08472684 -0.8550134 0.6855598 -1.262779 1.093325
## 588    -0.08157456 -0.8532290 0.6900798 -1.261718 1.098569
## 589    -0.08347907 -0.8562300 0.6892718 -1.265300 1.098341
## 590    -0.08580796 -0.8596844 0.6880685 -1.269350 1.097734
## 591    -0.08694756 -0.8620467 0.6881516 -1.272359 1.098464
## 592    -0.08691453 -0.8633073 0.6894782 -1.274305 1.100476
## 593    -0.08649499 -0.8641930 0.6912030 -1.275881 1.102891
## 594    -0.08618783 -0.8651741 0.6927984 -1.277544 1.105169
## 595    -0.08611376 -0.8663696 0.6941420 -1.279412 1.107185
## 596    -0.08616838 -0.8676850 0.6953483 -1.281395 1.109058
## 597    -0.08623627 -0.8690126 0.6965400 -1.283389 1.110917
## 598    -0.08626684 -0.8703039 0.6977702 -1.285348 1.112814
## 599    -0.08626515 -0.8715628 0.6990325 -1.287274 1.114744
## 600    -0.08625282 -0.8728095 0.7003039 -1.289187 1.116682
## 601    -0.08624426 -0.8740575 0.7015690 -1.291101 1.118612
## 602    -0.08624235 -0.8753097 0.7028250 -1.293017 1.120532
## 603    -0.08624402 -0.8765633 0.7040752 -1.294933 1.122445
## 604    -0.08624595 -0.8778151 0.7053232 -1.296847 1.124355
## 605    -0.08624678 -0.8790641 0.7065705 -1.298756 1.126263
## 606    -0.08624671 -0.8803102 0.7078167 -1.300662 1.128169
## 607    -0.08624635 -0.8815540 0.7090613 -1.302564 1.130072
## 608    -0.08624611 -0.8827961 0.7103038 -1.304464 1.131972
## 609    -0.08624606 -0.8840363 0.7115442 -1.306361 1.133869
plot(forecast(fit, 30))